package com.sky.controller.admin;

import com.sky.result.Result;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;

/**
 * PROJECT_NAME: sky-take-out
 * NAME: ShopController
 *
 * @AUTHOR: zhang
 * DATE: 2023/11/28
 * DESCRIPTION :
 */
@Slf4j
@Api(tags = "B端-营业状态信息表现层接口") //@Api:用户描述类的相关信息
@RestController("adminShopController")
@RequestMapping("/admin/shop")
public class ShopController {
    @Resource
    private RedisTemplate redisTemplate;

    public static final String SHOP_STATUS="SHOP_STATUS";

    @ApiOperation("设置店铺状态")
    @PutMapping("/{status}")
    public Result modifyShopStatus(@PathVariable Integer status){
        log.info("【设置店铺状态】，{}",status);
        redisTemplate.opsForValue().set(SHOP_STATUS,status);
        return Result.success();
    }

    @ApiOperation("获取店铺状态")
    @GetMapping("/status")
    public Result getShopStatus(){
        log.info("【获取店铺状态】");
        Integer shopStatus = (Integer) redisTemplate.opsForValue().get(SHOP_STATUS);
        return Result.success(shopStatus);
    }
}
